lines = []
try:
    while True:
        line = input()
        if line == '':
            break
        lines.append(line)
except:
    pass

errors = []
for line in lines:
    info = line.split(' ')
    filename = info[0].split('\\')[-1]
    if len(filename) > 16:
        filename = filename[-16:]
    linenum = int(info[1])
    ptr = None
    for err in errors:
        if filename == err['filename'] and linenum == err['linenum']:
            ptr = err
            break
    if ptr != None:
        ptr['count'] += 1
    else:
        err = {'filename': filename, 'linenum': linenum, 'count': 1}
        errors.append(err)

for err in errors[-8:]:
    print(err['filename'], err['linenum'], err['count'])
